package com.bidepan.spring6.tx.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class CheckoutServiceImpl implements CheckoutService{

    @Autowired
    private BookService bookService;

    @Transactional()
    //买多本书的方法
    @Override
    public void checkout(Integer[] bookIds, Integer userId) {
        for(Integer bookId : bookIds){
            //对每本书调用service的方法
            bookService.buyBook(bookId, userId);
        }
    }
}
